<?php namespace App\Modules\Admin\Controllers;

use App\Http\Requests;
use Illuminate\Http\Request;
use App\Modules\Common\Controller as CommonController;
use Illuminate\Support\Facades\Config;

/**
 * Base admin section controller
 *
 * @author Todor Todorov <todstoychev@gmail.com>
 * @package App\Http\Controllers\Admin
 */
class Controller extends CommonController {

    /**
     * @inheritdoc
     */
    public function __construct() {
        parent::__construct();
        $this->middleware('admin_permissions');
    }
    
    /**
     * Missing method handler
     * 
     * @param array $parameters
     * @return \Illuminate\View\View
     */
    public function missingMethod($parameters = array())
    {
        return view('errors.404', ['admin' => 'admin::'.Config::get('view.admin_template') . '.vendor.']);
    }

    /**
     * Make a admin view render
     *
     * @param null $view
     * @param array $data
     * @param array $mergeData
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    protected function render($view = null, $data = [], $mergeData = []){
        return view('admin::'.Config::get('view.admin_template') . '.' . $view, $data, $mergeData);
    }
}
